monad (圈)
triple。餘 standard 構成
モナド (圏論) - Wikipedia
Monad (category theory) - Wikipedia
monad in nLab
Triple, Monad, Cotriple, Comonad
圈$ \bf Cに於いて、自己函手$ T:{\bf C}\to{\bf C}と自然變換$ \mu:(T;T)\Rarr T,$ \eta:{\rm Id}_{\bf C}\Rarr Tの組$ (T,\eta,\mu)は、以下を滿たせば monad (圈) と呼ぶ
但し
$ T\muとは各對象$ x_{\in|{\bf C}|}に就いて自然變換$ \muの成分$ \mu_xを函手$ Tに依って移した射$ T(\mu_x)を成分とした自然變換であり、
$ T\mu:=\{T(\mu_x)|\mu_x:(T;T)(x)\to T(x)\}
$ T\eta:=\{T(\eta_x)|\eta_x:x\to T(x)\}
$ \mu Tとは各對象$ x_{\in|{\bf C}|}に就いて自然變換$ \muの對象$ T(x)に於ける成分$ \mu_{T(x)}を成分とした自然變換である
$ \mu T:=\{\mu_{T(x)}|\mu_{T(x)}:(T;T)(T(x))\to T(T(x))\}
$ \eta T:=\{\eta_{T(x)}|\eta_{T(x)}:T(x)\to T(T(x))\}
整合條件 (coherence 條件)
可換圖式$ \begin{CD}T;T;T @>T\mu>> T;T \\ @V\mu TVV @VV\mu V \\ T;T @>>\mu > T\end{CD}
$ T\mu;\mu=\mu T;\mu
結合律の類似
可換圖式$ \begin{CD}T @>T\eta>> T;T \\ @V\eta TVV @VV\mu V \\ T;T @>>\mu> T\end{CD}
$ T\eta;\mu={\rm Id}_T=\eta T;\mu
單位律の類似
←→餘 monad (comonad。cotriple。standard 構成 (standard construction))
comonad in nLab
自己函手の圈$ {\bf End}_{\bf C}に於ける餘 monoid
圈$ \bf Cに於いて、自己函手$ T:{\bf C}\to{\bf C}と自然變換$ \Delta:T\Rarr(T;T),$ \epsilon:T\Rarr{\rm Id}_{\bf C}の組$ (T,\epsilon,\Delta)は、以下を滿たせば 餘 monad と呼ぶ
可換圖式$ \begin{CD}T @>\Delta>> T;T \\ @V\Delta VV @VV\Delta TV \\ T;T @>>T\Delta> T;T;T\end{CD}
$ \Delta;\Delta T=\Delta;T\Delta
可換圖式$ \begin{CD}T @>\Delta>> T;T \\ @V\Delta VV @VV\epsilon TV \\ T;T @>>T\epsilon> T\end{CD}
$ \Delta;\epsilon T=\Delta;T\epsilon
單位 (圈)$ \eta・餘單位$ \epsilon
unit of a monad in nLab
隨伴 (函手)$ L\dashv Rを合成して monad (圈)$ L;R、餘 monad$ R;Lを構成できる。この設定に於いて、隨伴 (函手)の單位 (圈)$ \etaは monad (圈)の單位 (圈)$ \etaに一致し、隨伴 (函手)の餘單位$ \epsilonは 餘 monadの餘單位$ \epsilonに一致する
一般には、隨伴 (函手)$ T\dashv G關係にある monad (圈)$ Tと餘 monad$ Gの、隨伴 (函手)の單位 (圈)と monad (圈)の單位 (圈)、隨伴 (函手)の餘單位と餘 monad の餘單位は一致しないが、mate 關係にはなる
mate in nLab
$ \mathbf{Set}上で單位元附き monoid$ Mをひとつ固定します。
• 左隨伴$ T = (-)\times Mと右隨伴$ G = (-)^M(評價・curry 化の隨伴 (函手)) で$ T \dashv G。
• 隨伴 (函手)の單位 (圈)・餘單位
$ \iota_X: X \to (X\times M)^M,\quad \iota_X(x)=\big(m\mapsto (x,m)\big),
$ \kappa_Y: Y^M\times M \to Y,\quad \kappa_Y(f,m)=f(m).
• $ Mを monoid と見ると$ Tは「Writer monad」:
$ \eta_X: X\to X\times M,\quad \eta_X(x)=(x,e),\qquad\mu_X: (X\times M)\times M \to X\times M,\ (x,m_1,m_2)\mapsto(x,m_1m_2).
• $ Gは對應する「Reader 餘 monad」:
$ \epsilon_Y: Y^M \to Y,\quad \epsilon_Y(f)=f(e),\qquad\delta_Y: Y^M \to (Y^M)^M,\ \delta_Y(f)(m_1)(m_2)=f(m_1m_2).
ここで $ \eta_X: X\to X\times M と $ \iota_X: X\to (X\times M)^M は型が違ふので一致のしようがなく、$ \epsilon_Y: Y^M\to Y と $ \kappa_Y: Y^M\times M\to Y も同樣に一致しません。
(ただし $ \eta の右 mate として $ \epsilon_Y=\kappa_Y\circ(\eta_{Y^M}) が得られる、といふ「mate 對應」は成り立ちます。)
monad (圈) は圈$ \bf Cの自己函手の圈$ {\bf End}_{\bf C}の monoid 對象である
$ {\bf End}_{\bf C}は函手圈$ {\bf C}^{\bf C}である
對象は圈$ \bf C上の自己函手$ F:{\bf C}\to{\bf C}
射は自己函手の閒の自然變換$ F\Rarr G
嚴密 monoidal 圈である
自己函手の合成を tensor 積とする$ F\otimes G:=F;G
恆等函手$ {\rm Id}_{\bf C}を單位 (圈)とする
結合律子は等式が成り立つ$ (F;G);H=F;(G;H)
左右の單位律子は等式が成り立つ$ {\rm Id}_{\bf C};F=F=F;{\rm Id}_{\bf C}
monad (圈)$ (T,\eta,\mu)は$ {\bf End}_{\bf C}の monoid 對象である
$ \mu:(T;T)\Rarr Tが乘法である
$ \eta:{\rm Id}_{\bf C}\Rarr Tが單位射である
$ {\bf End}_{\bf C}の monoid 對象は monad (圈)$ (T,\eta,\mu)である
乘法が$ \mu:(T;T)\Rarr Tである
單位射が$ \eta:{\rm Id}_{\bf C}\Rarr Tである
弱 2-圈での定義
モナド論をヒントに圏論をする(弱2-圏の割と詳しい説明付き) - 檜山正幸のキマイラ飼育記 (はてなBlog)
自明な2-圈から2-圈CATへのラックス2-函手である
嚴密 monad
Strong monad - Wikipedia
strong monad in nLab
整合條件が自然同型ではなく等式として成り立つ場合を言ふ
痩せた圈に於ける monad (圈) は閉包作用素$ \rm clである
monad (圈) は隨伴函手の理論で使われ、半順序 (poset)上の閉包作用素を任意の圈の上へ一般化する。
半順序 (poset)$ (P,\le)から生成される圈(對象が$ Pの元であり、$ x\le yが成り立つとき$ xから$ yへ射が1つ與へられる)を特別に考へると、隨伴 (函手)の對は Galois 接續(en:Galois connection)、monad (圈) は閉包作用素(en:closure operator)といふ單純な對應が取れる。
冪等 monad (idempotent monad)
idempotent monad in nLab
圈$ \bf Cに於ける monad (圈)$ (T,\mu,\eta)は、以下の同値な條件のどれかを滿たせば冪等 monad である
$ \mu:(T;T)\Rarr Tが自然同型
$ \mu:(T;T)\Rarr Tを構成する射 (component) が mono 射
maps$ T\eta,\eta T:T\to(T;T)が equal
つまり$ (T,\eta)が well-pointed endofunctor
well-pointed endofunctor in nLab
全ての$ T-代數 (圈) (a.k.a.$ T-module)$ (M,\mu)に於いて$ T-作用$ u:TM\to Mが同型である (卽ち全ての代數 (圈)は不動點である)
The 忘卻函手$ {\bf C}^T\to{\bf C}(where$ {\bf C}^Tis the Eilenberg-Moore 圈 of$ T-algebras) is a 充滿忠實函手である
There exists a pair of adjoint functors$ F\dashv Usuch that the induced monad$ (T:UF,\mu:=U\in F,\eta)is isomorphic to$ (T,\mu,\eta)and$ Uis a 充滿忠實函手である
There is a 充滿部分圈$ U:{\bf C}^T\hookrightarrow{\bf C}and a natural bijection of the form$ {\bf C}(T(c),U(a))\to{\bf C}(c,U(a)),(T(c)\xrightarrow{f}U(a))\mapsto(c\xrightarrow{\eta}T(c)\xrightarrow{f}U(a))
The identity natural transformation$ TT\Rarr TTis a distributive law.
←→冪等餘 monad
programming に於ける monad (圈)
モナド (プログラミング) - Wikipedia
Monad (functional programming) - Wikipedia
しかし、函數型プログラミングの文脈におけるモナドは通常は圏論における強モナドを指すことが多い。
monad (in computer science) in nLab
monad (in linguistics) in nLab
Kleisli triple$ (T,\eta,\_^*)は、(fmap, unit, bind)
code:unit と bind に依る定義.hs
unit :: x -> M x
bind :: M x -> (x -> M y) -> M y
-- 律
bind (unit x) f == f x
do { y <- f x; return y } == f x
bind m unit == m
do { return m } == m
bind (bind m f) g == bind m (\x -> bind (f x) g)
unit は return とも書く
unit と bind に依る定義は do 糖衣構文にとって自然
code:unit と fmap と join に依る定義.hs
unit :: x -> M x
fmap :: (x -> y) -> M x -> M y
join :: M (M x) -> M x
-- 律
fmap id == id
fmap (f . g) == (fmap f) . (fmap g)
unit . f == fmap f . unit
join . fmap join == join . join
join . fmap unit == join . unit
join . fmap (fmap f) == fmap f . join
code:bind と (fmap, join) との關係.hs
fmap f m == bind m (unit . f)
join m == bind m id
bind m g == join (fmap g m)
一意型
單位 (圈) return | 餘單位 extract
monad 變換子
adjoint monad in nLab
monadic adjunction in nLab
monadic functor in nLab
comonadic functor in nLab
hypermonoid in nLab
monad・餘 monad の隨伴對への分解